<?php

namespace tmcore\services\crud\enum;

/**
 * 表单类型枚举
 */
class FormTypeEnum
{
    // 输入框(兼容密码)
    const INPUT = 'input';
    // 文本域
    const TEXTAREA = 'textarea';
    // 数字输入框
    const NUMBER = 'number';
    // 下拉框(兼容多选)
    const SELECT = 'select';
    // 单选框
    const RADIO = 'radio';
    // 复选框
    const CHECKBOX = 'checkbox';
    // 日期选择器
    const DATE_PICKER = 'datePicker';
    // 时间选择器
    const TIME_PICKER = 'timePicker';
    // 图片选择器(兼容多选)
    const IMAGE_SELECT = 'imageSelect';
    // 视频选择器(兼容多选)
    const VIDEO_SELECT = 'videoSelect';
    // 文件选择器(兼容多选)
    const FILE_SELECT = 'fileSelect';
    // 用户信息选择器(兼容多选)
    const USER_SELECT = 'userSelect';
    // 省市区选择器
    const AREA_SELECT = 'areaSelect';
    // 富文本编辑器
    const EDITOR = 'editor';

    const FORM_TYPE = [
        self::INPUT,
        self::TEXTAREA,
        self::NUMBER,
        self::SELECT,
        self::RADIO,
        self::CHECKBOX,
        self::DATE_PICKER,
        self::TIME_PICKER,
        self::IMAGE_SELECT,
        self::VIDEO_SELECT,
        self::FILE_SELECT,
        self::USER_SELECT,
        self::AREA_SELECT,
        self::EDITOR,
    ];

    const DICT_FORM_TYPE = [
        self::SELECT,
        self::RADIO,
        self::CHECKBOX,
    ];

    /**
     * 获取表单类型描述
     * @param bool $value
     * @return string|string[]
     */
    public static function getFormTypeDesc($value = true)
    {
        $data = [
            self::INPUT => '输入框',
            self::TEXTAREA => '文本域',
            self::NUMBER => '数字输入框',
            self::SELECT => '下拉框',
            self::RADIO => '单选框',
            self::CHECKBOX => '复选框',
            self::DATE_PICKER => '日期选择器',
            self::TIME_PICKER => '时间选择器',
            self::IMAGE_SELECT => '图片选择器',
            self::VIDEO_SELECT => '视频选择器',
            self::FILE_SELECT => '文件选择器',
            self::USER_SELECT => '用户信息选择器',
            self::AREA_SELECT => '省市区选择器',
            self::EDITOR => '富文本编辑器',
        ];
        if ($value === true) {
            return $data;
        }
        return $data[$value] ?? '';
    }

}
